<include file="public@header"/>
<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}">
        <input readonly="readonly" id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
        <input readonly="readonly" class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
               style="width: 200px;" title="文件名称">
        <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
      <!--   <a href="javascript:uploadOne('图片上传','#file-{id}');">替换</a> -->
        <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
    </li>
</script>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input readonly="readonly" id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input readonly="readonly" class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
      <!--   <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a> -->
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">

			<li><a href="{:url('Order/index')}">运营中心</a></li>
			<li><a href="{:url('Order/addOrder')}">添加</a></li>
			<!-- 	<li class="active><a href="{:url('station/index')}">园区添加</a></li> -->
			<li class="active"><a href="javascript:;">编辑</a></li>
		</ul>

		<form method="post" class="form-horizontal  margin-top-20" action="editOrder">
		    <input readonly="readonly" type="hidden" name="incubator_id" value="">
			<input readonly="readonly" type="hidden" name="space_name" value="">
			<input readonly="readonly" type="hidden" name="customer_name" value="">
			<input readonly="readonly" type="hidden" name="id" value="{$detail.id}">
			<input readonly="readonly" type="hidden" name="room_id" value="{$detail.space_id}">
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">租赁类型<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<select readonly="readonly" class="form-control  space_type" name="space_type" id="parent_id"  required="true">
						<option value="">==请选择==</option>
						<option value="1" <if condition="$detail.space_type eq 1">selected</if>>空间</option>
						<option value="2" <if condition="$detail.space_type eq 2">selected</if>>场地</option>
						
					</select>
				</div>
			</div>

			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">空间名称</label>
				<div class="col-md-6 col-sm-10">
					<select readonly="readonly" class="form-control space_name" name="space_id" id="parent_id" required="true">
						<option value="">==请选择==</option>
					
						
					</select>
				</div>
			</div>
				<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">面积<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="mobile" value="{$detail.cover_area}" required="true">
				</div>
			</div>
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">客户名<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<select readonly="readonly" class="form-control " name="customer_id" id="parent_id" required="true" >
						<option value="">==请选择==</option>
						<volist name="customers" id="vo">
						  <option value="{$vo.id}" <if condition="$detail.customer_id eq $vo.id">selected</if>>{$vo.customer_name}</option>
						</volist>
					
						
					</select>
				</div>
			</div>
			<!-- <div class="form-group" >
				<label for="input-name" class="col-sm-2 control-label">状态</label>
				<div class="col-md-6 col-sm-10">
					<select readonly="readonly" class="form-control" name="status" id="parent_id" required="true">
						<option value="">==请选择==</option>
						<option value="1" <if condition="$detail.status eq 1">selected</if>>可用</option>
						<option value="0" <if condition="$detail.status eq 0">selected</if>>禁用</option>
						
					</select>
				</div>
			</div> -->
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">电话<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="mobile" value="{$detail.mobile}" required="true">
				</div>
			</div>
		<!-- 	<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">图片<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="pic" value="" >
				</div>
			</div> -->
			<!-- <div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">图<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="pic_url" value="" required="true">
				</div>
			</div> -->
			<!-- <div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">合同附件<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
				 <ul id="photos" class="pic-list list-unstyled form-inline"></ul>
                            <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                               class="btn btn-default btn-sm">选择图片</a>
				</div>
			</div> -->
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">图片</label>
				<div class="col-md-6 col-sm-10">
					<imagetpl name="pic" id="img" value="$detail['pic']"/>
				</div>
			</div>
			<!-- <div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">单价<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="price" value="" >
				</div>
			</div> -->
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">数量<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="amount" value="{$detail.amount}" >
				</div>
			</div>
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">服务费<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="service_price" value="{$detail.service_price}" >
				</div>
			</div>
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">押金<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="deposit_price" value="{$detail.deposit_price}" >
				</div>	<a class="btn btn-danger"  id="back_deposit">退押金</a>
			</div>
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">是否开收据</label>
				<div class="col-md-6 col-sm-10">
					<select readonly="readonly" class="form-control" name="is_receipt" id="parent_id">
						<option value="">==请选择==</option>
						<option value="1" <if condition="$detail.is_receipt eq 1">selected</if>>是</option>
						<option value="0" <if condition="$detail.is_receipt eq 0">selected</if>>否</option>
						
					</select>
				</div>
			</div>
			<!-- <div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">租金总额<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="sum_price" value="{$detail.sum_price}" >
				</div>
			</div> -->
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">支付方式</label>
				<div class="col-md-6 col-sm-10">
					<select readonly="readonly" class="form-control" name="payway_id" id="parent_id" required="true">
						<option value="">==请选择==</option>
						<option value="1" <if condition="$detail.payway_id eq 1">selected</if>>年</option>
						<option value="2" <if condition="$detail.payway_id eq 2">selected</if>>半年</option>
						<option value="3" <if condition="$detail.payway_id eq 3">selected</if>>季度</option>
						<option value="4" <if condition="$detail.payway_id eq 4">selected</if>>月</option>
						<option value="5" <if condition="$detail.payway_id eq 5">selected</if>>次</option>
						
					</select>
				</div>
			</div>


		<!-- 	<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">空间名称<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="space_name" value="" required="true">
				</div>
			</div> -->
		<!-- 	<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">合同时间<span class="form-required">*</span></label>
		
				<div class="col-md-6 col-sm-10 space">
				
					<input readonly="readonly" type="text" class="form-control js-bootstrap-date " name="stime"
					value="{$detail.start_time}"
					 required="true">-
					<input  readonly="readonly" type="text" class="form-control js-bootstrap-date" name="etime"
					value="{$detail.end_time}"
					  required="true">
				</div>
			
			</div> -->
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">合同时间<span class="form-required">*</span></label>
			<!-- 	<div class="col-md-6 col-sm-10">
				
					<input type="text" class="form-control js-bootstrap-datetime" name="stime"
					value="{$detail.start_time}"
					 required="true">-
					<input type="text" class="form-control js-bootstrap-datetime" name="etime"
					value="{$detail.end_time}"
					  required="true">
				</div> -->
				<div class="col-md-6 col-sm-10 space">
				
					<input readonly="readonly" type="text" class="form-control js-bootstrap-date " name="stime"
					value="{$detail.start_time}"
					 required="true">-
					<input readonly="readonly" type="text" class="form-control js-bootstrap-date" name="etime"
					value="{$detail.end_time}"
					  required="true">
				</div>
				<div class="col-md-6 col-sm-10 site" style="display: none">
				
					<input readonly="readonly" type="text" class="form-control js-bootstrap-datetime " name="stime"
					value="{$detail.start_time}"
					 required="true">-
					<input readonly="readonly" type="text" class="form-control js-bootstrap-datetime" name="etime"
					value="{$detail.end_time}"
					  required="true">
				</div>
			</div>


		<!-- 	<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">业务员<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="text" name="salesman" value="{$detail.salesman}" >
				</div>
			</div> -->
			<div class="form-group" >
				<label for="input-name" class="col-sm-2 control-label">业务员<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<!-- <input class="form-control" type="text" name="other_link" value="" > -->
					<select class="form-control" name="salesman" id="parent_id" readonly="readonly">
						<option value="">==选择业务员==</option>
						<volist name="salesman" id="vo">
								<option value="{$vo.id}" <if condition="$vo['id'] eq $detail['sales_id']">selected</if>>{$vo.user_login}</option>
						</volist>
					<!-- 	<option value="1">电话</option>
						<option value="2">来访</option>
						<option value="3">熟人介绍</option>
						<option value="4">其他</option> -->
					

					</select>
				</div>
			</div>
			<!-- <div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">合同附件<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input readonly="readonly" class="form-control" type="file" name="file" value="" >
				</div>
			</div> -->
			<div class="form-group">
				<label for="input-name" class="col-sm-2 control-label">合同附件<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<!-- <ul id="files" class="pic-list list-unstyled form-inline">
					</ul>
					<a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl');"
					class="btn btn-sm btn-default">选择文件</a> -->
					<ul id="files" class="pic-list list-unstyled form-inline">
						<notempty name="arrs">
						<foreach name="arrs" item="vo">
								<php>$file_url=cmf_get_file_download_url($vo['url']);</php>
								<li id="saved-file{$key}">
									<input readonly="readonly" id="file-{$key}" type="hidden" name="file_urls[]"
									value="{$vo.url}">
									<input readonly="readonly" class="form-control" id="file-{$key}-name" type="text"
									name="file_names[]"
									value="{$vo.name}" style="width: 200px;" title="图片名称">
								<!-- 	<a id="file-{$key}-preview" href="{$file_url}" target="_blank">下载</a>
									<a href="javascript:uploadOne('图片上传','#file-{$key}');">替换</a>
									<a href="javascript:(function(){$('#saved-file{$key}').remove();})();">移除</a> -->
								</li>
							</foreach>
						</notempty>
					</ul>
					<!-- <a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl');"
					class="btn btn-sm btn-default">选择文件</a> -->
				</div>
			</div>


			

		</div>
			
<!-- 				<label for="input-remark" class="col-sm-2 control-label">备注</label> -->
			<!-- 	<div class="col-md-6 col-sm-10">
					<label class="radio-inline js-icheck"><input readonly="readonly" type="radio" name="status" value="1" checked>显示</label>
					<label class="radio-inline js-icheck"><input readonly="readonly" type="radio" name="status" value="0" <if condition="1">checked</if>>隐藏</label>
				</div> -->
			<!-- </div>  -->
			<!-- <div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
				
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
					<a class="btn btn-default" href="{:url('index',['type_id'=>1])}">{:lang('BACK')}</a>
				</div>
			</div> -->
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
	var type=$(".space_type").val();
	if(type==2){

		$(".site").css('display','');
		$(".space").css('display','none');
	}else{
		$(".site").css('display','none');
		$(".space").css('display','');
	}
	$(".space_type").change(function(){
		var b=$(".space_name option:first").text();  
		$(".space_name").html('<option>'+b+'</option>');  
		var space_id=<?php echo $detail['space_id']; ?>;
		var type=$(".space_type").val();
		 if(type==2){
        
        	$(".site").css('display','');
        	$(".space").css('display','none');
        }else{
        	$(".site").css('display','none');
        	$(".space").css('display','');
        }
		var option;
        $.post("{:url('Order/get_space')}",{type:type},function(data,status){
        	$.each(data,function(i,j){

        		if(type==1){

        			if(space_id==j.id){
        				option+='<option value='+j.id+' selected>'+j.station_name+'</option>';	
        			}else{
        				option+='<option value='+j.id+'>'+j.station_name+'</option>';
        			}

        		}else{
        			if(space_id==j.id){
        				option+='<option value='+j.id+'>'+j.site_name+'</option>';
        			}else{
        				option+='<option value='+j.id+'>'+j.site_name+'</option>';
        			}
        		}
        		
        	})
        	$(".space_name").append(option);
        })
       // alert(option);
   })
	$(function(){
		var id=<?php echo $detail['id']; ?>;	
		var space_id=<?php echo $detail['space_id']; ?>;
		var type=$(".space_type").val();
		var option;
		$.post("{:url('Order/get_space')}",{type:type,edit:1,space_id:space_id},function(data,status){
			$.each(data,function(i,j){

				if(type==1){

					if(space_id==j.id){
						option+='<option class='+j.incubator_id+' value='+j.id+' selected>'+j.station_name+'</option>';	
					}else{
						option+='<option class='+j.incubator_id+' value='+j.id+'>'+j.station_name+'</option>';
					}

				}else{
					if(space_id==j.id){
						option+='<option class='+j.incubator_id+' value='+j.id+' selected>'+j.site_name+'</option>';
					}else{
						option+='<option class='+j.incubator_id+' value='+j.id+'>'+j.site_name+'</option>';
					}
				}

			})
			$(".space_name").append(option);


       })

       $("#back_deposit").click(function(){
			if(confirm("是否确定退还押金？")){
				 $.post("{:url('Order/backDeposit')}",{id:id},function(data,status){
				 	alert('押金退还成功');	
				 	$("input[name=deposit_price]").val('0.00');
				 })
			}
		
		   })	





	})
	$(".space_name").change(function(){
		name=$(this).find("option:selected").text();
		$("input[name=space_name]").val(name);
	})
	$("select[name=customer_id]").change(function(){
		name=$(this).find("option:selected").text();
		$("input[name=customer_name]").val(name);
	})
	$(".space_name").change(function(){
		// val=$(this).attr('class');
		// alert(val);
		val=$(".space_name option:selected").attr("class");
		$("input[name=incubator_id]").val(val);
		//alert(val);
	})

	
</script>
</body>
</html>